import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

array = [r'E:/images/pic2.png']
for img in array:
    imgs = cv.imread(img)
    gray = cv.cvtColor(imgs, cv.COLOR_BGR2GRAY)  # 转换为灰度图
    retval, dst = cv.threshold(gray, 0, 255, cv.THRESH_OTSU)  # 使用大津算法进行图像二值化


    cv.imshow("dst", dst)

cv.waitKey()
cv.destroyAllWindows()